home *** CD-ROM | disk | FTP | other *** search
- library ISAPIForum;
-
- uses
- Windows,
- SysUtils,
- Classes,
- ISAPISock,
- Httpext,
- Parser;
-
- procedure ProcessGet(sock: TISAPISock);
- var
- fin: TextFile;
- s: String;
- begin
- try
- with sock do
- begin
- // Send a HTML header
- Writeln('HTTP/1.0 200 OK');
- Writeln('Content-type: text/html');
- Writeln('');
-
- // Start of body
- HPageStart;
- HHeading(3, 'Forum Discussion');
-
- // Dump out message database
- AssignFile(fin, ExtractFilePath(GetServerVariable('SCRIPT_NAME'))+'ForumMessages.txt');
- try
- Reset(fin);
- try
- while NOT EOF(fin) do
- begin
- Readln(fin, s);
- HLine(s);
- end;
- finally
- CloseFile(fin);
- end;
- except
- // Something bad happened.
- end;
-
- // Add a form so that the reader can add his/her own comments
- HFormStart('POST', '/bin/ISAPIForum.dll');
-
- HSeparator;
- HHeading(3, 'What do you think?');
- HTextArea('Your comments? ', 'UserComment', '', 60, 10);
- HLine('');
- HEditBox('Your Name: ', 'UserName', '', 50, 50);
- HFormEnd('Submit','Clear');
-
-
- // End the page
- HPageEnd;
- end;
- except
- // Something went wrong
- end;
- end;
-
- procedure ProcessPost(sock: TISAPISock);
- var
- fout: TextFile;
- s: String;
- begin
- try
- with sock do
- begin
- // Send a HTML header
- Writeln('HTTP/1.0 200 OK');
- Writeln('Content-type: text/html');
- Writeln('');
-
- // Start of body
- HPageStart;
-
- try
- AssignFile(fout, ExtractFilePath(GetServerVariable('SCRIPT_NAME'))+'ForumMessages.txt');
- Append(fout);
- try
- System.Writeln(fout,'****************');
- System.Writeln(fout, EscapeDecode(GetFormVal('UserName'))+' wrote on '+DateTimeToStr( Now ) );
- System.Writeln(fout, EscapeDecode(GetFormVal('UserComment')) );
- finally
- CloseFile(fout);
- end;
- except
- // Something bad happened
- HLine('Something bad has happened');
- end;
-
- HLine('Your comment has been noted! Thanks!');
- HPageEnd;
- end;
- finally
- // Something went wrong
- end;
- end;
-
- // CASE MATTERS FOR THIS FUNCTION NAME
- function GetExtensionVersion(var ver: THSE_VERSION_INFO): Boolean; stdcall;
- begin
- result:=True;
- end;
-
- // CASE MATTERS FOR THIS FUNCTION NAME
- function HttpExtensionProc(var ecb: TEXTENSION_CONTROL_BLOCK): LongInt; stdcall;
- var
- sock: TISAPISock;
- method: String;
- begin
- // Create the socket helper
- sock:=TISAPISock.Create(ecb);
-
- // Was this a GET or POST?
- method:=sock.GetServerVariable('REQUEST_METHOD');
- if method='GET' then
- begin
- ProcessGet(sock)
- end
- else if method='POST' then
- begin
- ProcessPost(sock)
- end
- else
- begin
- // Don't understand this...
- sock.Writeln('HTTP/1.0 200 OK');
- sock.Writeln('Content-type: text/html');
- sock.Writeln('');
- sock.Writeln('I didn''t understand that request');
- end;
-
-
- // Return a normal status code
- StrLCopy( ecb.lpszLogData, PChar('DLL Finished with no errors'), HSE_LOG_BUFFER_LEN-1);
- Result:=HSE_STATUS_SUCCESS;
-
- // Free the socket
- sock.Free;
- end;
-
- // * REQUIRED FOR DYNAMIC BINDING.
- // * Index values aren't need.
- // * Case doesn't matter here.
- exports
- GetExtensionVersion,
- HttpExtensionProc;
-
- begin
- end.
-